package zhr.chapter7;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;

public class Example7_7 {
    public static void main(String[] args) {
        TimeZone timezoneAL = TimeZone.getTimeZone("America/Los_Angeles");
        Calendar calDefault = Calendar.getInstance();
        Calendar calAL = Calendar.getInstance(timezoneAL);
        String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
        sdf.setTimeZone(TimeZone.getTimeZone(calDefault.getTimeZone().getID()));
        System.out.println("本机所在时区为：" + calDefault.getTimeZone().getID() + "，当前时间是：" + sdf.format(calDefault.getTime()));
        System.out.println("洛杉矶所在时区为：" + calAL.getTimeZone().getID() + "，当前时间是：" + sdf.format(calAL.getTime()));
    }

}
